<?php


namespace app\services\utils;


use dh2y\qrcode\QRcode;

class QrcodeService
{
    public static function createQrcode($url, $userId, $inviteCode, $logo)
    {
        $code = new QRcode();
        //生成二维码
        $rootPath = public_path();
        $path = '/upload/qrcode/' . $userId . '.png';
        $filePath = $rootPath . $path;
        $code->png($url, $filePath, 14)
            ->logo($logo)
            ->background(192, 710)
//            ->text('二维码', 20, ['center', 460], '#ff4351')
            ->text($inviteCode, 50, ['center', 1450], '#ff4351');
        return $path;
    }


    public static function createUserQrcode($url, $userId)
    {
        $code = new QRcode();
        //生成二维码
        $rootPath = public_path();
        $path1 = '/uploads/qrcode/' . $userId.'_'.time().'_code.png';
        $codePath = $rootPath . $path1;
        $res = $code->png($url, $codePath, 6);
        return $path1;
    }
}